/*  1:   */ package org.jeecgframework.poi.excel.view;
/*  2:   */ 
/*  3:   */ import java.net.URLEncoder;
/*  4:   */ import java.util.Collection;
/*  5:   */ import java.util.List;
/*  6:   */ import java.util.Map;
/*  7:   */ import javax.servlet.ServletOutputStream;
/*  8:   */ import javax.servlet.http.HttpServletRequest;
/*  9:   */ import javax.servlet.http.HttpServletResponse;
/* 10:   */ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/* 11:   */ import org.apache.poi.ss.usermodel.Workbook;
/* 12:   */ import org.jeecgframework.poi.excel.ExcelExportUtil;
/* 13:   */ import org.jeecgframework.poi.excel.entity.ExportParams;
/* 14:   */ import org.jeecgframework.poi.excel.export.ExcelExportServer;
/* 15:   */ import org.springframework.stereotype.Controller;
/* 16:   */ 
/* 17:   */ @Controller("jeecgExcelView")
/* 18:   */ public class JeecgSingleExcelView
/* 19:   */   extends MiniAbstractExcelView
/* 20:   */ {
/* 21:   */   protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
/* 22:   */     throws Exception
/* 23:   */   {
/* 24:48 */     String codedFileName = "临时文件";
/* 25:49 */     Workbook workbook = null;
/* 26:50 */     if (model.containsKey("mapList"))
/* 27:   */     {
/* 28:51 */       List<Map<String, Object>> list = (List)model.get("mapList");
/* 29:53 */       if (list.size() == 0) {
/* 30:54 */         throw new RuntimeException("MAP_LIST IS NULL");
/* 31:   */       }
/* 32:56 */       workbook = ExcelExportUtil.exportExcel((ExportParams)((Map)list.get(0)).get("params"), (Class)((Map)list.get(0)).get("entity"), (Collection)((Map)list.get(0)).get("data"));
/* 33:60 */       for (int i = 1; i < list.size(); i++) {
/* 34:61 */         new ExcelExportServer().createSheet(workbook, (ExportParams)((Map)list.get(i)).get("params"), (Class)((Map)list.get(i)).get("entity"), (Collection)((Map)list.get(i)).get("data"));
/* 35:   */       }
/* 36:   */     }
/* 37:   */     else
/* 38:   */     {
/* 39:67 */       workbook = ExcelExportUtil.exportExcel((ExportParams)model.get("params"), (Class)model.get("entity"), (Collection)model.get("data"));
/* 40:   */     }
/* 41:72 */     if (model.containsKey("fileName")) {
/* 42:73 */       codedFileName = (String)model.get("fileName");
/* 43:   */     }
/* 44:75 */     if ((workbook instanceof HSSFWorkbook)) {
/* 45:76 */       codedFileName = codedFileName + ".xls";
/* 46:   */     } else {
/* 47:78 */       codedFileName = codedFileName + ".xlsx";
/* 48:   */     }
/* 49:80 */     if (isIE(request)) {
/* 50:81 */       codedFileName = URLEncoder.encode(codedFileName, "UTF8");
/* 51:   */     } else {
/* 52:83 */       codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
/* 53:   */     }
/* 54:85 */     response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
/* 55:86 */     ServletOutputStream out = response.getOutputStream();
/* 56:87 */     workbook.write(out);
/* 57:88 */     out.flush();
/* 58:   */   }
/* 59:   */ }


/* Location:           C:\Users\Administrator\.m2\repository\org\jeecgframework\easypoi-web\2.1.4\easypoi-web-2.1.4\
 * Qualified Name:     org.jeecgframework.poi.excel.view.JeecgSingleExcelView
 * JD-Core Version:    0.7.0.1
 */